<template>
   <div>
      <v-btn :btnConfig="btnConfig" @poFill="create" @btnTableData="btnTableData" @tableDelete="tableDelete"></v-btn>
      <v-table
          :hasEdit="false"
          :pageFlag="false"
          :searchFlag="false"
          :pageSize="pageSize"
          :page="page"
          :tableConfig="tableConfig"
          :tableData="tableData"
          :total="total"
          @findData="getTableData"
          @getTableData="getTableData"
          @searhData="searhData"
          @selectData="selectData"
          @upData="getTableData"
          ref="table"
      ></v-table>
   </div>
</template>

<script>
import table from "commons/Table";
import btn from "@/components/commons/TableTitle";

export default {
   name: "",
   data() {
      return {
         btnConfig: [
            {
               type: "table", label: this.$t('common.create'), invalid: "po", tableConfig: [
                  {
                     label: this.$t('out.orderkey'),
                     prop: "orderkey",
                  },
               ],

            },
            {label: this.$t('common.delete'), invalid: "tableDelete"},
         ],
         url: ``,
         tableConfig: [
            {
               label: this.$t('out.orderkey'),
               prop: "orderkey",
            },
            {
               label: this.$t('in.externreceiptkey2'),
               prop: "externorderkey",
            },
            {
               label: this.$t('bill.orderType'),
               prop: "type",
            },
            {
               label: this.$t('out.contact1'),
               prop: "contact1",
            },
            {
               label: this.$t('config.phone'),
               prop: "phone1",
            },
            {
               label: this.$t('bill.province'),
               prop: "state",
            },
            {
               label: this.$t('bill.city'),
               prop: "city",
            },
            {
               label: this.$t('config.area'),
               prop: "county",
            },
            {
               label: this.$t('app.addDate'),
               prop: "adddate",
               input: "date"
            },
            {
               label: this.$t('app.addName'),
               prop: "addwho",
            },
         ],
         tableData: [],
         pageSize: 10,
         page: 1,
         total: 10,
         tableSearhData: {},
         tableSelectData: [],
      }
   },
   methods: {
      async btnTableData(page, date, callback, searchData) {
         let url = this.url;
         try {
            let res = await this.$api.post(`${url}${page}`, searchData);
            callback(res);
         } catch (e) {
            this.$message.error(e);
         }
      },
      create(data) {

      },

      async tableDelete() {
         if (this.tableSelectData.length === 0) {
            this.$message.error(this.$t('msg.msg16'));
            return;
         }
         if (this.$parent.$input.inputData.status != "0") {
            this.$message.error(this.$t('msg.msg59'));
            return;
         }
         let orderkeyArr = this.$parent.$input.inputData.toString();
         try {
            let res = await this.$api.post(`/delOrder`, {
               whseid: this.$parent.whseid,
               opeuser: this.$parent.opeuser,
               users: this.$parent.users,
               shippingkey: this.$parent.$refs.input.inputData.shippingkey,
               orderkeyArr: orderkeyArr
            })
            if (res.data.type === "error") {
               this.$message.error(res.data.msg);
               this.errorPlay();
            } else {
               //重写
            }
         } catch (e) {
            this.$message.error(this.$t('app.err'));
            this.errorPlay();
         }
      },
      selectData(data) {
         this.tableSelectData = data;
      },
      async getTableData(page, data) {
         /* try {
             this.loading = true;
             let res = await this.$api.post(`/queryAltskuList/${page}`, data);
             
                this.tableData = res.page.list;
                this.page = res.page.curpage;
                this.pageSize = res.page.pageSize;
                this.total = res.page.total;
             } else {
                this.$message.error(res.returnMgr);
             }
          } catch (e) {
             this.$message.error(error);
          } finally {
             this.loading = false;
          }*/
      },
      //搜索的值
      searhData(data, up) {
         if (!up) {
            this.tableSearhData = data;
         } else {
            this.tableSearhData = data;
            this.getTableData(1, this.tableSearhData);
         }
      },
   },
   mounted() {
   },
   components: {
      "v-table": table,
      "v-btn": btn,
   }
}
</script>

<style scoped>

</style>
